package com.huluobo.a2201mvvm_imdemo.mvvm;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import com.blankj.utilcode.util.ToastUtils;
import com.huluobo.a2201mvvm_imdemo.net.NetUtils;

/**
 * Created by LC on 2024/3/22.
 */
public abstract class BaseActivity<VDB extends ViewDataBinding> extends AppCompatActivity {
    protected VDB dataBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        dataBinding = DataBindingUtil.setContentView(this, getLayoutId());
        initView();
        initData();
    }

    protected abstract void initData();

    protected abstract void initView();

    protected abstract int getLayoutId();

    @Override
    protected void onResume() {
        super.onResume();
        if (!NetUtils.getInstance(this).isConnected()) {
            ToastUtils.showLong("当前没有网络连接,请检查网络");
        }

        if (NetUtils.getInstance(this).isSlowlyNetwork()) {
            ToastUtils.showLong("当前网络有些慢,请检查网络连接");
        }
    }
}
